<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>求数组中的最值和所在位置</title>
	</head>
	<body>
		<script>
			var arr = [0, 5, -3, 6, 2, -6, 10];
         
          var maxValue = arr[0];
          var minValue = arr[0];
          var maxIndex = 0;
          var minIndex = 0;
          for (var i = 1; i < arr.length; i++) {
              if(arr[i] > maxValue){
        
                maxValue = arr[i];
                 maxIndex = i;
             }
            
             if (arr[i] < minValue) {
                 minValue = arr[i];
                 minIndex = i;
            }
         }
         console.log(maxValue);
         console.log(maxIndex);
        console.log(minValue);
         console.log(minIndex);
		</script>
	</body>
</html>
